package org.loofer.uikit;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.FrameLayout;

public class MarkFrameLayout extends FrameLayout implements Markable {
    private Marker mMarker;

    public MarkFrameLayout(Context context) {
        super(context);
        init(null);
    }

    public MarkFrameLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(attrs);
    }

    public MarkFrameLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init(attrs);
    }

    private void init(AttributeSet attrs) {
        this.mMarker = new Marker(this, attrs);
    }

    public void setMarkerVisible(boolean visible) {
        this.mMarker.setMarkerVisible(visible);
    }

    public void setMarkerVisibleWhenSelected(boolean visible) {
        this.mMarker.setMarkerVisibleWhenSelected(visible);
    }

    public boolean isMarkerVisible() {
        return this.mMarker.isMarkerVisible();
    }

    public void setMarker(int resId) {
        this.mMarker.setMarker(resId);
    }

    public void setMarker1(int resId) {
        this.mMarker.setMarker1(resId);
    }

    public void setMarker2(int resId) {
        this.mMarker.setMarker2(resId);
    }

    public void setMarker3(int resId) {
        this.mMarker.setMarker3(resId);
    }

    public void setMarkerAutoPadding(boolean enable) {
        this.mMarker.setMarkerAutoPadding(true);
    }

    public void setMarker(Drawable marker) {
        this.mMarker.setMarker(marker);
    }

    public void setMarker1(Drawable marker) {
        this.mMarker.setMarker1(marker);
    }

    public void setMarker2(Drawable marker) {
        this.mMarker.setMarker2(marker);
    }

    public void setMarker3(Drawable marker) {
        this.mMarker.setMarker3(marker);
    }

    public void setMarkerPosition(int position) {
        this.mMarker.setMarkerPosition(position);
    }

    public void setMarkerType(int markerType) {
        this.mMarker.setMarkerType(markerType);
    }

    public void setMarkerCount(int count) {
        this.mMarker.setMarkerCount(count);
    }

    public void setMarkerText(String text) {
        this.mMarker.setMarkerText(text);
    }

    public void setMarkerTextSize(int textSize) {
        this.mMarker.setMarkerTextSize(textSize);
    }

    public void setMarkerTextColor(int textColor) {
        this.mMarker.setMarkerTextColor(textColor);
    }

    public void setMarkerPaddingOffset(int xOffset, int yOffset) {
        this.mMarker.setMarkerPaddingOffset(xOffset, yOffset);
    }

    public void setMarkerSize(int width, int height) {
        this.mMarker.setMarkerSize(width, height);
    }

    public void getMarkerSize(int[] size) {
        this.mMarker.getMarkerSize(size);
    }

    public void setOnMarkerClickListener(OnMarkerClickListener listener) {
        this.mMarker.setOnMarkerClickListener(listener);
    }

    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
        this.mMarker.updateMarkerLayout();
    }

    protected void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(canvas);
        this.mMarker.draw(canvas);
    }

    public boolean onTouchEvent(MotionEvent event) {
        return this.mMarker.onTouchEvent(event) || super.onTouchEvent(event);
    }
}
